home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1988 October
/
Ahoy_Magazine_88-10_1988_Double_L.d64
/
Factor Fun 2
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
627b
|
22 lines
0 print"[147]":poke53280,6:poke53281,0
1 rem ==================================
2 rem commodares problem #52-4 :
3 rem factor fun
4 rem solution by
5 rem claude landusky
6 rem ==================================
10 ti$="000000":print"initialization takes over an hour for n to reach 31627...":print:print"n ="
20 dim p(3500):p(0)=2:c=1
30 forn=3to31627step2:x=0:print n;
40 q=p(x):ifq*q>nthenp(c)=n:c=c+1:goto70
50 ifn/q=int(n/q)then70
60 x=x+1:goto40
70 next:print ti$
80 input"number to factor";n:ti$="000000":f=0:c=0:ifn>999999999then80
90 q=p(f):ifq*q>nthen120
100 ifn/q=int(n/q)thenn=n/q:c=1:printq;:goto100
110 f=f+1:goto90
120 ifc=0thenprint"prime"=;:goto140
130 ifn<>1thenprintn;
140 print:printti$:goto80